﻿using ZXthex;

sealed class ExampleC :FromC
{
    delegate int GetAFunction();
    delegate void SetAFunction(int value);

    GetAFunction fun;
    SetAFunction fun2;

    /// <summary>
    /// 
    /// #include "stdafx.h"
    ///
    /// static int a;
    ///
    /// EXTERN_C{
    ///
    /// 	__declspec(dllexport)  int getA()
    ///     {
    ///         return a;
    ///     }
    ///
    ///     __declspec(dllexport)  void setA(int value)
    ///     {
    ///        a = value;
    ///     }
    /// }
    /// 
    /// </summary>
    public ExampleC() : base(@"dlls/Dll3x.dll")
    {
        fun = GetFunction<GetAFunction>("getA");
        fun2 = GetFunction<SetAFunction>("setA");
    }

    public int Get()
    {
        return fun();
    }

    public void Set(int value)
    {
        fun2(value);
    }

}
